package com.fesine.spring.framework;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/12/4 19:40
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/12/4 19:40
 */
public class WorkerRunnable implements Runnable {

    private String name;
    private int tickets =10;

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if (this.tickets > 0) {
                System.out.println(Thread.currentThread().getName()+ " 卖票---->" + (this.tickets--));
            }
        }
    }

    public static void main(String[] args) {
        //只有一个对象，分配的三个线程对一个对象操作
        WorkerRunnable wr = new WorkerRunnable();
        Thread t1 = new Thread(wr, "1号窗口");
        Thread t2 = new Thread(wr, "2号窗口");
        Thread t3 = new Thread(wr, "3号窗口");
        t1.start();
        t2.start();
        t3.start();
    }
}
